/**
 * @(#)AuthenticationService.java 2011
 *
 * Copyright 2011 classic-commerce
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

package ca.ioniq.server.service;

import ca.ioniq.server.service.exception.AuthenticationException;
import ca.ioniq.server.service.impl.AuthenticationServiceImpl;
import ca.ioniq.shared.entity.User;

import com.google.inject.ImplementedBy;

/**
 * @author: <a href="mailto:richard@ioniq.ca">Richard Mutezintare</a>
 */

@ImplementedBy(AuthenticationServiceImpl.class)
public interface AuthenticationService {
	
	/**
	 * Create an account for a user.
	 * @param user the user to be created
	 * @return true if creation was successfull false otherwise
	 */
	User createAccount(User user) throws AuthenticationException;
	
	/**
	 * A user is deleted by another user in the administrator role. The user will be linked with the database if is not.
	 * @param subject the deleted user
	 * @param principal the user in administrator role
	 * @return true if the subject is in  database and principal is an administrator else throw an exception
	 */
	boolean deleteAccount(User subject, User principal) throws AuthenticationException;
	
	/**
	 * Update user account. The user will be linked with the database if is not.
	 * @param subject the user to be updated
	 * @param principal the user in administrator role
	 * @return true if the subject is in  database and principal is an administrator; else throw an exception
	 */
	boolean updateAccount(User subject, User principal) throws AuthenticationException;

    /**
     *
     * @param subject the user to be
     * @return
     * @throws AuthenticationException
     */
    boolean authenticate(User subject) throws AuthenticationException;
}
